home *** CD-ROM | disk | FTP | other *** search
- ** sysmon.i
- **
- ** $Filename: sysmon.i $
- ** $Revision: 1.16 $
- ** $Date: 2001/04/28 14:12:44 $
- **
- *******************************************************************************
- ** definition of sysmon.library base and internal structures (version 1.18)
- *******************************************************************************
- **
- ** Copyright (c) 1995-2002 by Etienne Vogt.
- **
-
- IFND SYSMON_I
- SYSMON_I SET 1
-
- IFND EXEC_LIBRARIES_I
- INCLUDE "exec/libraries.i"
- ENDC
-
- IFND EXEC_SEMAPHORES_I
- INCLUDE "exec/semaphores.i"
- ENDC
-
- IFND EXEC_MEMORY_I
- INCLUDE "exec/memory.i"
- ENDC
-
- IFND DEVICES_TIMER_I
- INCLUDE "devices/timer.i"
- ENDC
-
- IFND DOS_DATETIME_I
- INCLUDE "dos/datetime.i"
- ENDC
-
- * library data structure
- * All field in the SysmonBase structure are PRIVATE !!!
- * Don't access these directly as they will change in future versions.
- * You have been warned !!!
-
- HASHSIZE EQU 32
- HASHMASK EQU $f8
-
- STRUCTURE SysmonBase,LIB_SIZE ; Standard lib node
- UBYTE sb_Flags ; Some flags here
- UBYTE sb_pad ; We are now longword aligned
- APTR sb_ExecBase ; Pointer to exec
- APTR sb_UtilityBase ; Pointer to utility
- BPTR sb_SegList ; SegList BCPL pointer
- APTR sb_CurrTaskInfo ; Current TaskInfo Structure
- APTR sb_Switch ; Original Switch() entry point
- APTR sb_Dispatch ; Original Dispatch() entry point
- APTR sb_AddTask ; Original AddTask() entry point
- APTR sb_RemTask ; Original RemTask() entry point
- APTR sb_FindTask ; Original FindTask() entry point
- APTR sb_Alert ; Original Alert() entry point
- APTR sb_ExitIntr ; Original ExitIntr() entry point
- APTR sb_Schedule ; Original Schedule() entry point
- APTR sb_Exception ; Original Exception() entry point
- APTR sb_SetTaskPri ; Original SetTaskPri() entry point
- APTR sb_SetExcept ; Original SetExcept() entry point
- APTR sb_SetSignal ; Original SetSignal() entry point
- APTR sb_Signal ; Original Signal() entry point
- APTR sb_Wait ; Original Wait() entry point
- APTR sb_TaskExit ; Original ExecBase->TaskExitCode
- APTR sb_TaskExcept ; Original ExecBase->TaskExceptCode
- APTR sb_TaskTrap ; Original ExecBase->TaskTrapCode
- STRUCT sb_TimeReq,IOTV_SIZE ; Time Request
- STRUCT sb_TempTime,EV_SIZE ; Temporary EClock Time
- STRUCT sb_TaskFrozen,LH_SIZE ; List of frozen tasks
- BYTE sb_ResetBit ; Signal bit for reset handler
- UBYTE sb_ResetFlags ; Flags for reset handler
- STRUCT sb_TaskInfoHash,4*HASHSIZE ; TaskInfo hash table
- APTR sb_ServerEntry ; Server process entry point
- APTR sb_ServerName ; Server process name
- APTR sb_SyslogFile ; SysLog file name
- APTR sb_SyslogWindow ; Syslog Window Name
- UBYTE sb_FilePri ; File logging priority
- UBYTE sb_WindowPri ; Window logging priority
- UBYTE sb_ConsolePri ; Console logging priority
- UBYTE sb_NumLogBuffers ; Number of allocated Buffers
- APTR sb_Buffers ; Pointer to allocated buffers
- APTR sb_DOSBase ; Pointer to dos
- APTR sb_DateTime ; struct DateTime used by syslog
- ULONG sb_StampPeriod ; Period for syslog file stamp
- BPTR sb_LogWindowHandle ; LogWindow file handle
- APTR sb_IntuitionBase ; Pointer to intuition
- APTR sb_LastGuru ; Pointer to LastGuru structure
- APTR sb_SyslogPort ; Pointer to Syslog MsgPort
- APTR sb_ServerProc ; Pointer to server process
- APTR sb_ResetHandler ; Pointer to reset handler
- APTR sb_ResetReq ; Pointer to reset request
- STRUCT sb_BCPSem,SS_SIZE ; Semaphore for Broadcast Ports list
- STRUCT sb_BroadcastPorts,MLH_SIZE ; List of Registered Broadcast Ports
- STRUCT sb_TTASem,SS_SIZE ; Semaphore for Task Table Access
- STRUCT sb_TTRSem,SS_SIZE ; Semaphore for Task Table Removal
- STRUCT sb_CPUTime,EV_SIZE ; Total CPU Time used by tasks
- APTR sb_MMUBase ; Pointer to mmu library
- APTR sb_ColdReboot ; Cached ColdReboot() vector
- ULONG sb_VolTSw ; Voluntary Task Switches counter
- ULONG sb_InvTSw ; Involuntary Task Switches counter
- STRUCT sb_LdAvrVBLInt,IS_SIZE ; Load Average VBL Interrupt
- UWORD sb_LdAvrPtr ; Pointer in Load Average circular buffer
- STRUCT sb_LdAvrBuffer,15*60 ; Load Average circular Buffer, updated every
- ; second from the sysmon.library VBlank interrupt
- ULONG sb_QuantumExp ; Global Quantum Expiration counter
- APTR sb_SuperState ; Original SuperState() entry point
- APTR sb_UserState ; Original UserState() entry point
- LABEL SysmonBase_SIZEOF
-
- * The TaskInfo structure contains the CPU usage information in EClock ticks.
- * The link pointers are private and should not be used. Use the smNextTaskInfo()
- * function to traverse the list.
- * This structure may be extended later with new fields. Also all fields are
- * strictly READ ONLY.
-
- STRUCTURE TaskInfo,0
- APTR ti_Link ; private pointer to next TaskInfo
- APTR ti_Pred ; private pointer to previous TaskInfo
- APTR ti_Task ; pointer to Task Control Block
- ULONG ti_DispCount ; Task Dispatch counter
- STRUCT ti_StartTime,EV_SIZE ; Starting EClock Time
- STRUCT ti_LaunchTime,EV_SIZE ; Last Launch Time
- STRUCT ti_CPUTime,EV_SIZE ; Cumulated CPU Time
- UBYTE ti_Flags ; Various flags
- UBYTE ti_ExcptState ; Task State saved by Exception()
- BYTE ti_EDNestCnt ; Exception Disable Nest Count
- UBYTE ti_FreezeState ; Task State saved by smFreeze()
- ULONG ti_VolTSw ; Voluntary Task Switches counter
- ULONG ti_InvTSw ; Involuntary Task Switches counter
- ULONG ti_QuantumExp ; Quantum Expiration counter
- LABEL TaskInfo_SIZEOF
-
- * ti_Flags bits
-
- BITDEF TI,INEXCEPT,0 ; Task is inside Exception code
- BITDEF TI,WAKEUP,1 ; A WakeUp request is pending
-
- * This is the private structure used by smVSysLog() to communicate with the
- * Sysmon.server process.
-
- SM_MAXLOGCHARS EQU 256 ; Max bytes in SysLog message
-
- STRUCTURE SysLogMsg,MN_SIZE ; Message structure
- ULONG slm_Priority ; SysLog priority and flags
- STRUCT slm_Text,SM_MAXLOGCHARS ; Syslog Message body
- LABEL SysLogMsg_SIZEOF
-
- SYSMONNAME MACRO
- DC.B 'sysmon.library',0
- ENDM
-
- SERVERNAME MACRO
- DC.B 'Sysmon.server',0
- ENDM
-
- * sb_Flags bits
-
- BITDEF SBF,FPU,0 ; System has a FPU
- BITDEF SBF,IDLELED,1 ; Dim power LED when CPU is idle
- BITDEF SBF,MMU,2 ; System has a MMU (according to mmu.library)
- BITDEF SBF,MACOSKLUDGE,3 ; Try to be friendly to MacOS emulators
- BITDEF SBF,SUPERSTATE,7 ; PRIVATE flag for smSuperState()
-
- * sb_ResetFlags bits
-
- BITDEF SBRST,ACTIVATE,0 ; Activate reset handler
- BITDEF SBRST,PENDING,1 ; Reset is pending
- BITDEF SBRST,OLDMMU,2 ; Restore old MMU setup before reboot
- BITDEF SBRST,CACHEREBOOT,3 ; Use a cached ColdReboot() vector
-
- * Alert definitions
- * These are the Guru codes that sysmon.library can spit out in a panic
- * condition.
-
- AN_Sysmon EQU $40000000 ; SubSystem ID
- AN_smNoTaskInfo EQU $40000001 ; No TaskInfo structure for this task
- AN_smNoTIMem EQU $40010002 ; No mem for TaskInfo at startup
- AN_smSysLogBuf EQU $40010003 ; No memory for syslog buffers
- AN_BadSysLogMsg EQU $40000004 ; Bad SysLogMsg received by server
- AN_smNoLastGuru EQU $40010005 ; No memory for LastGuru buffer
- AN_smNoAlertMem EQU $40010006 ; No memory for new alert.hook module
- AN_smSuperTaskSwitch EQU $C0000007 ; Attempt to switch task from supervisor mode
- AN_smInconSchedState EQU $C0000008 ; Inconsistant Scheduling State
- AO_Sysmon EQU $00008040 ; Alert object
-
- * These are reused obsolete exec alert codes
-
- AN_UnInitExcpt EQU $0100000A ; Uninitialized task exception (not CPU trap)
-
- * New Task States Definitions (not all used yet !)
- * TS_STOP is not a real state. It is used by ShowSys to identify tasks that
- * are stuck in a Wait(0) call, such as crashed tasks that have been suspended.
-
- TS_STOP EQU $80 ; Stopped task (Wait(0L))
- TS_FROZEN EQU $81 ; Frozen task
- TS_HIBERNATE EQU $82 ; Hibernating task
- TS_PAGEFLTWAIT EQU $83 ; Task suspended for page fault processing
- TS_WAITAND EQU $84 ; Task waiting for several signals set together
- TS_TRAP EQU $85 ; Task suspended by exception trap code
- TS_FREEWAIT EQU $86 ; Task waiting for free memory
-
- * SysLog priorities and flags
- * The priorities are similar to that used on UNIX systems. This means that
- * the values use the UNIX ordering that is reversed from the Amiga one.
- * The facilities are also UNIX like and indicate what part of the system
- * produced the message. This is purely informational currently.
- * The flags are Amiga and sysmon specifics.
-
- * Priorities
-
- LOG_EMERG EQU 0 ; Panic condition (Guru time)
- LOG_ALERT EQU 1 ; Very serious problem
- LOG_CRIT EQU 2 ; Critical error
- LOG_ERR EQU 3 ; General error condition
- LOG_WARN EQU 4 ; Warning condition
- LOG_NOTICE EQU 5 ; Noticeable event
- LOG_INFO EQU 6 ; General informational event
- LOG_DEBUG EQU 7 ; Debugging information
- LOG_PRI EQU $7 ; Mask for priority field
-
- * Facilities
-
- LOG_NOFAC EQU (0<<3) ; no facility
- LOG_KERN EQU (1<<3) ; kernel/system messages
- LOG_USER EQU (2<<3) ; random user-level messages
- LOG_MAIL EQU (3<<3) ; mail system
- LOG_DAEMON EQU (4<<3) ; system daemons/commodities
- LOG_AUTH EQU (5<<3) ; security/authorization messages
- LOG_SYSLOG EQU (6<<3) ; messages generated internally by Syslog
- LOG_NEWS EQU (7<<3) ; network news subsystem
- LOG_UUCP EQU (8<<3) ; UUCP subsystem
- LOG_CRON EQU (9<<3) ; cron/queue_manager subsystem
- LOG_AUTHPRIV EQU (10<<3) ; private security/authorization messages
- LOG_FTP EQU (11<<3) ; ftp daemon
- * other codes through 15 reserved for system use
- LOG_LOCAL0 EQU (16<<3) ; reserved for local use
- LOG_LOCAL1 EQU (17<<3) ; reserved for local use
- LOG_LOCAL2 EQU (18<<3) ; reserved for local use
- LOG_LOCAL3 EQU (19<<3) ; reserved for local use
- LOG_LOCAL4 EQU (20<<3) ; reserved for local use
- LOG_LOCAL5 EQU (21<<3) ; reserved for local use
- LOG_LOCAL6 EQU (22<<3) ; reserved for local use
- LOG_LOCAL7 EQU (23<<3) ; reserved for local use
- LOG_MARK EQU (24<<3) ; special time stamp mark
- LOG_UNKNOWN EQU (25<<3) ; unknown facility code
- LOG_FAC EQU $03f8 ; Mask for facility field
-
- * Flags
-
- LOG_INUSE EQU $80000000 ; Message is in use (private !)
- LOG_NOHEAD EQU $40000000 ; Don't prepend header
- LOG_NOWIN EQU $20000000 ; Don't output to window
- LOG_NOFILE EQU $10000000 ; Don't output to file
-
- LOGB_INUSE EQU 31 ; Bit numbers for flags
- LOGB_NOHEAD EQU 30
- LOGB_NOWIN EQU 29
- LOGB_NOFILE EQU 28
-
-
- * Flags definitions for smHalt()
-
- BITDEF HALT,REBOOT,0 ; Reboot immediately
- BITDEF HALT,REKICK,1 ; Reload kickstart on MMU-Kicked systems.
-
- * Broadcast Message send via smSendBroadcastMsg()
- * The sender must allocate this structure and fill in the different fields.
-
- STRUCTURE BroadcastMsg,MN_SIZE ; Standard Message structure
- UBYTE bcm_Level ; Event Level
- UBYTE bcm_Flags ; Flags
- UWORD bcm_TimeOut ; Reply Time Out in ticks
- UWORD bcm_CountDown ; Countdown to Event in seconds
- UBYTE bcm_ReplyCount ; Reply count after sending
- UBYTE bcm_TimeOutCount ; Time Out count after sending
- APTR bcm_SenderTask ; Sender Task (Filled by smSendBroadCastMsg())
- APTR bcm_EventTxt ; Text describing the event
- STRUCT bcm_Reserved,4*4 ; Reserved for future expansion
- LABEL BCM_SIZEOF
-
- * defines for event levels
-
- BCM_HALT EQU 0 ; System Halt/Reboot imminent
- BCM_UNMOUNT EQU 1 ; FileSystems will be UnMounted now
- BCM_SHUTDOWN EQU 2 ; Shutdown countdown message
- BCM_URGENT EQU 3 ; Urgent Message
- BCM_NORMAL EQU 4 ; Normal Message
- BCM_DEBUG EQU 5 ; Debug Level Message
-
- * defines for bcm_Flags
-
- BITDEF BCM,DOOMSDAY,0 ; Keyboard reset pending (System reboot in 10 seconds at most)
- BITDEF BCM,CANCEL,1 ; A previously announced event has been cancelled
-
- * defines for smLockTaskTable()/smUnLockTaskTable() flags
-
- BITDEF LTT,READ,0 ; Read access to task table
- BITDEF LTT,WRITE,1 ; Write access (PRIVATE !)
- BITDEF LTT,REMOVE,2 ; Prevent task removal
-
-
- * The LastGuru structure contains information about the last Guru Meditation
- * The data is stored in a high memory buffer by Alert() that is allocated by
- * sysmon.library during initialisation.
- * As this buffer is allocated early with AllocMem(MEMF_REVERSE), it will be
- * kept at the same address after reboot. This trick was already used successfully
- * on recoverable ram disks like vdisk.device
- * Some Fields are only valid if the corresponding register exists on the CPU
- * installed in the system.
-
- STRUCTURE LastGuru,MC_SIZE ; leave space for a memory chunk
- ULONG lg_Sig ; Alert signature ('HELP')
- ULONG lg_AlertNum ; Guru Meditation number
- ULONG lg_AlertAddr ; TCB Address of crashed task
- STRUCT lg_TaskName,32 ; Task name limited to 32 bytes
- STRUCT lg_DataRegs,8*4 ; Data registers D0-D7
- STRUCT lg_AddrRegs,8*4 ; Address registers A0-A7
- STRUCT lg_FloatRegs,8*12 ; Floating point registers FP0-FP7
- ULONG lg_FPCR ; Floating Point Control Register
- ULONG lg_FPSR ; Floating Point Status Register
- ULONG lg_FPIAR ; Floating Point Instruction Address Register
- ULONG lg_PC ; Program Counter
- ULONG lg_USP ; User Stack Pointer
- ULONG lg_SSP ; Supervisor/Interrupt Stack Pointer
- ULONG lg_MSP ; Master Stack Pointer / Processor Control Register [68060]
- ULONG lg_VBR ; Vector Base Register
- ULONG lg_SFC ; Source Function Codes
- ULONG lg_DFC ; Destination Function Codes
- ULONG lg_CACR ; Cache Control Register
- ULONG lg_TC ; Translation Control register
- ULONG lg_ITT0 ; Intruction Transparent Translation 0
- ULONG lg_ITT1 ; Intruction Transparent Translation 1
- ULONG lg_DTT0 ; Data Transparent Translation 0 / Common Root Pointer [68030]
- ULONG lg_DTT1 ; Data Transparent Translation 1 / Common Root Pointer [68030]
- ULONG lg_URP ; User Root Pointer / Supervisor Root Pointer [68030]
- ULONG lg_SRP ; Supervisor Root Pointer
- ULONG lg_MMUSR ; MMU Status Register / Bus Control Register [68060]
- ULONG lg_CAAR ; Cache Address Register
- UWORD lg_SR ; Status Register
- UWORD lg_AC ; Access Control register [68851]
- STRUCT lg_DRP,8 ; DMA Root Pointer [68851]
- STRUCT lg_BAD,8*2 ; Breakpoint Acknowledge Data registers [68851]
- STRUCT lg_BAC,8*2 ; Breakpoint Acknowledge Control registers [68851]
- UBYTE lg_CAL ; Current Access Level [68851]
- UBYTE lg_VAL ; Valid Access Level [68851]
- UBYTE lg_SCC ; Stack Change Control register [68851]
- UBYTE lg_Pad ; Padding byte
- LABEL lg_SizeOf
-
-
- * Function LVOs
-
- INCLUDE "exec/funcdef.i"
-
- FUNCINIT
- FUNCDEF smGetTaskInfo
- FUNCDEF smFreeze
- FUNCDEF smUnFreeze
- FUNCDEF smSleep
- FUNCDEF smVKPrintf
- FUNCDEF smVSPrintf
- FUNCDEF smVSysLog
- FUNCDEF smFindTaskInfo
- FUNCDEF smNextTaskInfo
- FUNCDEF smHalt
- FUNCDEF smVSnPrintf
- FUNCDEF smFindNode
- FUNCDEF smAddBroadcastPort
- FUNCDEF smRemBroadcastPort
- FUNCDEF smSendBroadcastMsg
- FUNCDEF smGetVBR
- FUNCDEF smMoveVBR
- FUNCDEF smLockTaskTable
- FUNCDEF smUnLockTaskTable
- FUNCDEF smDisallowExcept
- FUNCDEF smAllowExcept
- FUNCDEF smHibernate
- FUNCDEF smWakeUp
- FUNCDEF smScheduleWakeUp
- FUNCDEF smEndExcept
- FUNCDEF smWaitAnd
-
- ENDC ;SYSMON_I
-
-